import React from 'react';
import ReactDOM from 'react-dom';
import { createHashHistory } from 'history';
import { Router, Route, useRouterHistory } from 'react-router';
import { syncHistoryWithStore, RouterStore } from 'mobx-react-router';
import { Provider } from 'mobx-react';
import { WeaLicense, WeaLicenseSubmit, WeaPlugin, WeaNonStandard, WeaSystemSetting, WeaVersion } from 'weaPortalPublic';

const routing = new RouterStore();
const allStore = { routing };

const browserHistory = useRouterHistory(createHashHistory)({
  queryKey: '_key',
  basename: '/',
});

const history = syncHistoryWithStore(browserHistory, routing);

window.weaHistory = history;

class Home extends React.Component {
  render() {
    return this.props.children;
  }
}

class Root extends React.Component {
  render() {
    return (
      <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@zsyg5e`} {...allStore}>
        <Router ecId={`${this && this.props && this.props.ecId || ''}_Router@pi3t3y`} history={history}>
          <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@tha88c`} path="/" component={Home}>
            <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@kbaw79`} path="license" component={WeaLicense} />
            <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@fehnlr`} path="licensesubmit" component={WeaLicenseSubmit} />
            <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@uqx07q`} path="plugin" component={WeaPlugin} />
            <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@irwerj`} path="nonstandard" component={WeaNonStandard} />
            <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@2gmtgq`} path="systemsetting" component={WeaSystemSetting} />
            <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@tfcff0`} path="version" component={WeaVersion} />
          </Route>
        </Router>
      </Provider>
    );
  }
}

ReactDOM.render(<Root ecId={`${this && this.props && this.props.ecId || ''}_Root@avqv50`} />, document.getElementById('container'));
